﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Windows.Data; 

namespace ZhiHeng.OneCard.WpfClient.Common
{
    [ValueConversion(typeof (string), typeof (String))]
    public class DictionaryConverter : IValueConverter
    {
        /// <summary>
        /// ID转name
        /// </summary>
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            string str = ""; 
            var a = StaticDicdictionary.TreeDicdictionary;
            try
            {
               
                str =
                    (from p in a
                     where p.Code == int.Parse(value.ToString())
                     select p.Name).First();
            }
            catch
            {
            }
            a = null;
            return str;
        }

        public object ConvertBack(object value, Type targetTypes, object parameter, CultureInfo culture)
        {
            return null;
        }
    }
}
